package com.yang.service.impl;

import java.sql.SQLException;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Repository;

import com.yang.dao.DepartmentDAO;
import com.yang.service.DepartmentService;

@Repository("DepartmentServiceImpl")
public class DepartmentServiceImpl implements DepartmentService{

	@Resource(name="DepartmentDAOImpl")
	private DepartmentDAO dao;
	
	public List<Map<String, String>> getDepartmentList(String parentId)
			throws SQLException {
		
		return dao.getDepartmentList(parentId);
	}

	public String getDepartmentName(String deptId) throws SQLException {
		List<Map<String, String>> list = dao.getDepartmentName(deptId);
		
		String deptName = "";
		for(int i=0; i<list.size(); i++){
			Map<String, String> map = list.get(i);
			deptName += map.get("DEPT_NAME");
			if(list.size() > i+1 ){
				deptName += " > ";
			}
		}
		
		return deptName;
	}
	
	public List<Map<String, String>> getDeptFullNameList(String parentId) throws SQLException {
		
		return dao.getDeptFullNameList(parentId);
	}
	
}
